package com.mc.servlet;

import com.mc.bean.Match;
import com.mc.service.MatchService;
import com.mc.service.impl.MatchServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author wangcf
 * @version 1.0
 * @Description 赛事搜索控制器
 * @date 2023/2/16 19:21
 */
@WebServlet("/matchsearch.action")
public class MatchSearchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        MatchService matchService = new MatchServiceImpl();
        String search = req.getParameter("search");
        System.out.println(search);
        List<Match> matchList = matchService.find(search);
        System.out.println(matchList);
        req.setAttribute("matchlist",matchList);
        req.getRequestDispatcher("matchlist.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
